import token
from sqlalchemy import ForeignKey
from sqlalchemy.orm import (
    Mapped,
    mapped_column,
    relationship,
)
from typing import TYPE_CHECKING

from .base import Base

if TYPE_CHECKING:
    from .user import User


class TgChatReference(Base):
    __tablename__ = "tg_chat_reference"

    id: Mapped[int] = mapped_column(primary_key=True)
    chat_id: Mapped[int]
    tg_user_id: Mapped[int]
    user_id: Mapped[int] = mapped_column(ForeignKey("user.id", ondelete="CASCADE"))
    token: Mapped[str]

    user: Mapped["User"] = relationship()
